import {SETUSERINFO} from '../types'

export interface IUserState {
  userId:string|number,
  userName:string,
  token:string,
  nickName:string
}
let str = localStorage.getItem("userInfo");
const initState = str ? JSON.parse(str) : {
  userId:'',
  userName:'',
  token:'',
  nickName:''
}
export const userReducer = (state:IUserState=initState,action:any)=>{
  console.log(action,SETUSERINFO)
  switch (action.type) {
    case SETUSERINFO:
      return {
        ...action.userInfo
      }
    default:
      return {
        ...state
      }
  }
}